package com.hugang.principle.segregation;

interface Interface1 {
    void test1();

    void test2();

    void test3();

    void test4();

    void test5();
}

class D implements Interface1 {

    @Override
    public void test1() {
        System.out.println("D --> test1");
    }

    @Override
    public void test2() {
        System.out.println("D --> test2");

    }

    @Override
    public void test3() {
        System.out.println("D --> test3");

    }

    @Override
    public void test4() {
        System.out.println("D --> test4");

    }

    @Override
    public void test5() {
        System.out.println("B --> test5");

    }
}

class B implements Interface1 {

    @Override
    public void test1() {
        System.out.println("B --> test1");
    }

    @Override
    public void test2() {
        System.out.println("B --> test2");

    }

    @Override
    public void test3() {
        System.out.println("B --> test3");

    }

    @Override
    public void test4() {
        System.out.println("B --> test4");

    }

    @Override
    public void test5() {
        System.out.println("B --> test5");

    }
}

class A {
    B b = new B();

    public void test1() {
        b.test1();
    }

    public void test2() {
        b.test2();
    }

    public void test3() {
        b.test3();
    }

}

class C {
    D d = new D();

    public void test1() {
        d.test1();
    }

    public void test4() {
        d.test4();
    }

    public void test5() {
        d.test5();
    }

}

/**
 * 接口隔离原则
 *
 * 由于A依赖的B类实现了不必要的方法，C依赖的B类实现了不必要的方法，因此违反了接口隔离原则
 *
 * @author hg
 * @date 2020/9/6 16:30
 */
public class SegregationDemo1 {

    public static void main(String[] args) {

    }
}
